# -*- coding:utf-8 -*-
import enum

from enum import IntEnum

@enum.unique
class ETableStringKeyType(IntEnum):
    """
    TableString 中 key的唯一id生成方式
    """
    Seq = 1,
    DataInIndex = 2

    @classmethod
    def value_str(cls, key):
        key_map = {
            cls.Seq.value : "按数据顺序自动编号",
            cls.DataInIndex.value : "以数据组中指定索引位置的数据为key"
        }
        return key_map.get(key, "")

    @classmethod
    def is_contains(cls, key):
        for name, dataType in cls.__members__.items():
            if key == dataType.value:
                return True
        return False

if __name__ == "__main__":
    print(ETableStringKeyType.DataInIndex.value)
    print("---------------------------")
    print(ETableStringKeyType.value_str(ETableStringKeyType.DataInIndex.value))
    print("---------------------------")
    print(ETableStringKeyType.is_contains(ETableStringKeyType.DataInIndex.value))